package com.android.common.mobile;

import java.util.HashMap;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;

import com.android.common.mobile.i.ApnUriGetter;

public class ConnectionChangeReceiver extends BroadcastReceiver {

	private ApnUriGetter uriGetter;

	public ConnectionChangeReceiver(ApnUriGetter uriGetter) {
		this.uriGetter = uriGetter;
	}

	@Override
	public void onReceive(Context context, Intent intent) {
		HashMap<String, String> param = null;
		Uri[] uris = uriGetter.getUriList();
		for (int i = 0; i < uris.length; i++) {
			if (uris[i] != null)
				param = NetWork.getProxyInfo(context, uris[i]);
			if (param != null) {
				NetWork.setProxy(param.get("host"), param.get("port"));
				break;
			}
		}
	}

}
